04. Quiz: TeaTime Starting Code Walkthrough
TeaTime Code
The code for this app can be found in the TeaTime Repository. Download the repository using this command:
git clone https://github.com/udacity/AdvancedAndroid_TeaTime.git
If you need a refresher on how the code is organized, please refer to the TeaTime README for a detailed explanation.
Exercise Code
Exercise: TESP.00-StartingCode
Explanation of TeaTime
Throughout this lesson we’ll be using Espresso on the TeaTime app. I’ve coded up the basic functionality, and before we build it out any further, I’d like your help in testing various UI components. We want to develop with testing in mind so that we can catch potential bugs early on.
In the project, under app/main/java/com/example/android/teatime you’ll find these java files:
MenuActivity.java
This is the initial screen of the app. Users can select from a gridview of possible tea options.
OrderActivity.java
After the user selects a tea from MenuActivity, they are taken to an OrderActivity where they can customize the tea they have selected. There are 3 spinner setups (for size, milk, and sugar). The user can also change the quantity. The total price is updated according to the size selected and the quantity.
OrderSummaryActivity.java
Once the user hits the “Brew Tea” button in OrderActivity they are taken to the OrderSummaryActivity which displays details about the order just placed. On this screen the user also has the option to share and let their friends know that they are using this cool new app via an email intent.
TeaMenuAdapter.java
The TeaMenuAdapter is backed by an ArrayList of Tea objects which populate the GridView in MenuActivity.
Under app/main/java/com/example/android/teatime/model/ you'll find these files:
Tea.java
This class represents a tea that the user can select from the menu. It contains a tea name and an associated image.
In app/src/androidTest/java/com/example/android/teatime you'll find instrumented test files:
Instrumented Test
This lesson will focus on User Interface (UI) Tests which are a type of Instrumented Tests. Instrumented Tests need to be run on a physical device or emulator. There are a number of other types of tests available which we will explore later in this lesson.
Instrumented Tests are always located under module-name/src/androidTest/java/
Instrumented Tests are always found in the androidTest/java folder
You’ll notice that this app contains Views, AdapterViews, and Intents and this is no coincidence.
Espresso is helpful for testing:
- Views
- AdapterViews
- Intents
- Idling Resources
The last component, Idling Resource, is a new term. Idling Resources are used when testing any asynchronous code, for example long-running database operations that are off the main thread. We will cover testing this in-depth later in the lesson.
What is the name of the Instrumented Test?